{extend name="public/base" /}
{block name="container"}
<body class="gray-bg">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox">
                    <div class="ibox-content">
                        <h2>网站系统配置</h2>
                        <div class="clients-list">
                            <ul class="nav nav-tabs">
                                {volist name="class" id="vo" }
                                <li {if condition="$key+1 eq 1"}class="active"{/if}><a data-toggle="tab" href="#tab-{$key+1}"> {$vo.title}</a>
                                </li>
                                {/volist}
                                <li><a data-toggle="tab" href="#tab-10">新增变量</a></li>
                            </ul>
                            <div class="tab-content">
                                {volist name="class" id="vo"}    
                                <div id="tab-{$key+1}" {if condition="$key+1 eq 1"} class="tab-pane active"{else /} class="tab-pane" {/if}>
                                    <div class="full-height-scroll">
                                        <div class="table-responsive">
                                            <table class="table table-striped table-hover">
                                                <tbody>
                                                   {volist name="$vo['data']" id="da"} 
                                                   <tr>
                                                    <td class="client-avatar">{$da.varinfo}
                                                    </td>
                                                    <td></td>
                                                    <td class="contact-type">{$da.varname}</td>
                                                    <td >
                                                    {$da.varvalue}</td>
                                                    <td class="client-status"> <a data-toggle="modal" class="btn btn-primary" href="#modal-form" onclick="getInfo({$da.id})">编辑</a>
                                                    </td>
                                                </tr>
                                                {/volist}
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                            {/volist}
                            <div id="tab-10" class="tab-pane">
                                <div class="full-height-scroll">
                                    <div class="table-responsive">
                                        <form action="{:url('index/config/add')}" class="" method="post">
                                            <table class="table table-striped table-hover">
                                                <tbody>
                                                    <tr>
                                                      <td class="client-status"> 
                                                        <div class="form-group">
                                                            <label class="col-sm-5 control-label">所属配置组</label>
                                                            <div class="col-sm-10">
                                                                <select class="form-control m-b" name="vargroup" >
                                                                    {volist name="class" id="cl"}
                                                                    <option value="{$cl.id}">{$cl.title}</option>
                                                                    {/volist}
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="form-group">
                                                            <label class="col-sm-5 control-label">变量名称</label>

                                                            <div class="col-sm-10">
                                                                <input type="text" placeholder="系统会自动为变量添加'web_'前缀" class="form-control" id="cname" name="varname" type="text" class="form-control" required="" aria-required="true">
                                                            </div>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="form-group">
                                                            <label class="col-sm-5 control-label">参数说明</label>

                                                            <div class="col-sm-10">
                                                                <input type="text" placeholder="变量的描述信息" class="form-control" type="text" class="form-control" required="" aria-required="true" id="cinfo" name="varinfo">
                                                            </div>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                     <div class="form-group">
                                                        <label class="col-sm-5 control-label">变量值</label>
                                                        <div class="col-sm-10">
                                                            <input type="text" placeholder="请填写变量的值" class="form-control" required="" aria-required="true" id="value" name="varvalue">
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                   <div class="form-group">
                                                    <div class="col-sm-4 col-sm-offset-2">
                                                        <button class="btn btn-primary" type="submit">保存内容</button>
                                                        <button class="btn btn-white" type="reset">取消</button>
                                                    </div>
                                                </div> 
                                            </td>
                                        </tr>
                                    </tbody>
                                </form>
                            </table>
                        </div>
                    </div>
                </div> 
            </div>

        </div>
    </div>
</div>
</div>
</div>
</div>
</div>

<div id="modal-form" class="modal fade" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12 b-r">
                        <h3 class="m-t-none m-b">修改配置</h3>
                        <form role="form" action="" method="post">
                            <div class="form-group">
                                <label id="la">用户名：</label>
                                <input type="name" placeholder="请输入用户名" class="form-control" id="xiugai" name="varvalue">
                                <input type="hidden" id="bian" name="bianhao">
                            </div>
                            <div>
                                <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit"><strong>更新</strong>
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    {/block}
    {block name="js"}
    <script src="__INDEX__/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <!-- 自定义js -->
    <script src="__INDEX__/js/content.js?v=1.0.0"></script>

    <script>
        $(function () {
            $('.full-height-scroll').slimScroll({
                height: '100%'
            });
        });
    </script>
    <script>
        function getInfo(id)
        {
            $.post('/index/config/getInfo', {'id': id}, function(data) {
                if(data.success == 1){
                    document.getElementById('la').innerHTML = data.varinfo;
                    $('#xiugai').val(data.varvalue);
                    $('#bianhao').val(id);
                }
            });
        }
    </script>
    {/block}